Skip to content

[ENH] vectorize CLA _reduce_matrix using numpy advanced indexing#693

Merged
fkiraly merged 2 commits intoPyPortfolio:mainfrom
philippdubach:perf/vectorize-cla-reduce-matrix
Feb 26, 2026
Merged

[ENH] vectorize CLA _reduce_matrix using numpy advanced indexing#693
fkiraly merged 2 commits intoPyPortfolio:mainfrom
philippdubach:perf/vectorize-cla-reduce-matrix

Conversation

@philippdubach
Copy link
Contributor

Replace nested loop implementation with np.ix_ based vectorized selection. Performance improvement: 10-36x speedup depending on matrix size.

Benchmarks (100 iterations):

  • n=20: 10x faster
  • n=50: 18x faster
  • n=100: 12x faster
  • n=200: 34x faster
  • n=500: 37x faster

All existing CLA tests pass with identical numerical results.

Replace nested loop implementation with np.ix_ based vectorized selection.
Performance improvement: 10-36x speedup depending on matrix size.

Benchmarks (100 iterations):
- n=20:  10x faster
- n=50:  18x faster
- n=100: 12x faster
- n=200: 34x faster
- n=500: 37x faster

All existing CLA tests pass with identical numerical results.
@fkiraly fkiraly added the enhancement New feature or request label Feb 26, 2026
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, why was this even here? Thanks for spotting this.

@fkiraly fkiraly changed the title [ENH] vectorize CLA _reduce_matrix using numpy advanced indexing [ENH] vectorize CLA _reduce_matrix using numpy advanced indexing Feb 26, 2026
@fkiraly fkiraly merged commit da9f980 into PyPortfolio:main Feb 26, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants